package Ep06_BinaryTree.DFS.T3_0094;

import Ep06_BinaryTree.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/4/17 10:32
 * 说明：中序遍历  ——  递归写法
 */

public class InOrderTraversal_recursion {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        inOrder(root, res);
        return res;
    }
    public void inOrder(TreeNode root, List<Integer> res){
        if (root != null){
            inOrder(root.left, res);
            res.add(root.val);
            inOrder(root.right, res);
        }
    }
}
